// Package track 模型
package track

import (
	// "gitee.com/sweetsunnyflower/carpooling-server-go/pkg/logger"
	"gitee.com/sweetsunnyflower/carpooling-server-go/app/models"
	"gitee.com/sweetsunnyflower/carpooling-server-go/app/models/region"
	"gitee.com/sweetsunnyflower/carpooling-server-go/pkg/database"
)

// 路径表
type Track struct {
	models.BaseModel

	FromId uint64         `gorm:"column:from_id" db:"from_id" json:"from_id" form:"from_id"`
	ToId   uint64         `gorm:"column:to_id" db:"to_id" json:"to_id" form:"to_id"`
	From   *region.Region `gorm:"foreignKey:from_id" json:"from"`
	To     *region.Region `gorm:"foreignKey:to_id" json:"to"`

	models.CommonTimestampsField
}

func (track *Track) Create() {
	database.DB.Create(&track)
}

func (track *Track) Save() (rowsAffected int64) {
	result := database.DB.Save(&track)
	return result.RowsAffected
}

func (track *Track) Delete() (rowsAffected int64) {
	result := database.DB.Delete(&track)
	return result.RowsAffected
}
